//以下是赠送衬衫选择款式和尺码
	//衬衫赠送数量
	$('.size').on('click',function() {
		$("#cmmy").removeClass("none");
		var tr = $(this).parents('tr'); 
		var total_qty = tr.find('.total_qty').val();//赠送数量
		$('#gift_num').text(Math.floor(total_qty));
	})
	$(".cmclose").bind("click", function() {
		$("#cmmy").addClass("none");
	})
	//选择款式
	var stylesList = document.querySelector("#stylesList");
	stylesList && stylesList.addEventListener("click",function(e) {
		//$(this).children("li").removeClass("cm_checked");
		chooseSize(e);
	})
	//选择尺码
	var sizesList = document.querySelector("#sizesList");
	sizesList && (sizesList.onclick = function(e){
		chooseSize(e);
	})
	//选中衣服尺码（事件委托）
	function chooseSize(e) {
		var e = e || window.event;
		var target = e.srcElement || e.target;
		$(target).siblings().removeClass("cm_checked");
		if (target.tagName.toLowerCase() === "li") {
			//alert(target.textContent || target.innerText);
			$(target).addClass("cm_checked");
		}
		if(target.id == "mi"){
			$(".p_slt").attr('src',"http://www.hnhcyy.com/resource/zengping/zp_chengshan2.jpg");
		}
		if(target.id == "tiao"){
			$(".p_slt").attr('src',"http://www.hnhcyy.com/resource/zengping/zp_chengshan1.jpg");
		}
	}
	//检查是否选择规格尺寸
	function checkChoose(node) {
		var tag = false;
		$(node).each(function() {
			if($(this).children("li").hasClass("cm_checked")){
				tag = true;
				return false;//跳出循环
			}
		})
		return tag;
	}
	function showGiftInfo(){
		var zs_info = $(".zs_info");
		var info = "";
		zs_info.each(function(){
			info += $(this).html()+";";
		})
		return info;
	}
	var gifinfo = showGiftInfo();
	gifinfo && ($("#beizhu1").show(),$("#beizhu1 #msg").html(gifinfo));
	//选择尺码，确定按钮
	gifinfo += "[赠品衬衫：";
	var chooseCount = 0;
	$("#confirm").click(function(){
		 if(!checkChoose(stylesList)){
			 alert("请选择款式");
			 return; 
		 }
		 if(!checkChoose(sizesList)){
			 alert("请选择尺码");
			 return;
		 }
		 var style = $("#stylesList").find(".cm_checked").text(),
			 size = $("#sizesList").find(".cm_checked").text(),
			 giftNum = $("#gift_num").html();
		 if(chooseCount<sizeLength){
			 gifinfo += style+size+"码"+giftNum+"件；";
			 $("#beizhu1").show();
			 $("#beizhu1 #msg").html(gifinfo+"]");
			 chooseCount++;
		 }
		 $("#cmmy").addClass("none");
	})